<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="UTF-8" />
    <title>Menu - Basic</title>
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"
    />
    <link href="../../../../../css/ionic.bundle.css" rel="stylesheet" />
    <link href="../../../../../scripts/testing/styles.css" rel="stylesheet" />
    <script src="../../../../../scripts/testing/scripts.js"></script>
    <script nomodule src="../../../../../dist/ionic/ionic.js"></script>
    <script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script>

    <style>
      .my-custom-menu {
        --width: 500px;
      }

      .menu-part::part(backdrop) {
        background-color: rgba(255, 0, 255, 0.5);
      }

      .menu-part::part(container) {
        border-radius: 0 20px 20px 0;

        box-shadow: 4px 0px 16px rgba(255, 0, 255, 0.18);
      }
    </style>
  </head>
  <script type="module">
    import { menuController } from '../../../../dist/ionic/index.esm.js';
    window.menuController = menuController;
  </script>

  <body>
    <ion-app>
      <ion-menu
        side="start"
        id="start-menu"
        menu-id="start-menu"
        content-id="main"
        class="menu-part"
        aria-label="start menu"
      >
        <ion-header>
          <ion-toolbar color="primary">
            <ion-title>Start Menu</ion-title>
          </ion-toolbar>
        </ion-header>
        <ion-content>
          <ion-list>
            <ion-menu-toggle>
              <ion-button id="start-menu-button">Button</ion-button>
            </ion-menu-toggle>
            <ion-item>Menu Item</ion-item>
            <ion-item>Menu Item</ion-item>
            <ion-item>Menu Item</ion-item>
            <ion-item>Menu Item</ion-item>
            <ion-item>Menu Item</ion-item>
            <ion-item>Menu Item</ion-item>
            <ion-item>Menu Item</ion-item>
            <ion-item>Menu Item</ion-item>
            <ion-item>Menu Item</ion-item>
            <ion-item>Menu Item</ion-item>
            <ion-item>Menu Item</ion-item>
            <ion-item>Menu Item</ion-item>
            <ion-item>Menu Item</ion-item>
            <ion-item>Menu Item</ion-item>
            <ion-item>Menu Item</ion-item>
            <ion-item>Menu Item</ion-item>
            <ion-item>Menu Item</ion-item>
            <ion-item>Menu Item</ion-item>
            <ion-item>Menu Item</ion-item>
            <ion-item>Menu Item</ion-item>
          </ion-list>
        </ion-content>
      </ion-menu>

      <ion-menu side="start" menu-id="custom-menu" content-id="main" class="my-custom-menu">
        <ion-header>
          <ion-toolbar color="tertiary">
            <ion-title>Custom Menu</ion-title>
          </ion-toolbar>
        </ion-header>
        <ion-content>
          <ion-list>
            <ion-item>Menu Item</ion-item>
            <ion-item>Menu Item</ion-item>
            <ion-item>Menu Item</ion-item>
            <ion-item>Menu Item</ion-item>
            <ion-item>Menu Item</ion-item>
          </ion-list>
        </ion-content>
      </ion-menu>

      <ion-menu side="end" menu-id="end-menu" content-id="main" type="push">
        <ion-header>
          <ion-toolbar color="danger">
            <ion-title>End Menu</ion-title>
          </ion-toolbar>
        </ion-header>
        <ion-content>
          <ion-list>
            <ion-item>Menu Item</ion-item>
            <ion-item>Menu Item</ion-item>
            <ion-item>Menu Item</ion-item>
            <ion-item>Menu Item</ion-item>
            <ion-item>Menu Item</ion-item>
          </ion-list>
        </ion-content>
      </ion-menu>

      <div class="ion-page" id="main">
        <ion-header>
          <ion-toolbar>
            <ion-title>Menu - Basic</ion-title>
          </ion-toolbar>
        </ion-header>
        <ion-content class="ion-padding">
          <button class="expand" id="open-start" onclick="openStart()">Open Start Menu</button>
          <button class="expand" id="open-end" onclick="openEnd()">Open End Menu</button>
          <button class="expand" id="open-custom" onclick="openCustom()">Open Custom Menu</button>
        </ion-content>
      </div>
    </ion-app>

    <script>
      window.addEventListener('ionWillOpen', function (e) {
        console.log('ionWillOpen', e);
      });
      window.addEventListener('ionDidOpen', function (e) {
        console.log('ionDidOpen', e);
      });
      window.addEventListener('ionWillClose', function (e) {
        console.log('ionWillClose', e);
      });
      window.addEventListener('ionDidClose', function (e) {
        console.log('ionDidClose', e);
      });

      async function openStart() {
        // Open the menu by menu-id
        await menuController.enable(true, 'start-menu');
        await menuController.open('start-menu');
      }

      async function openEnd() {
        // Open the menu by side
        await menuController.open('end');
      }

      async function openCustom() {
        // Open the menu by menu-id
        await menuController.enable(true, 'custom-menu');
        await menuController.open('custom-menu');
      }
    </script>
  </body>
</html>
